package common;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import dataBase.DBManager;
import demiBoard.DemiBoard;
import demiChat.DemiChatModule;
import demiUser.DemiUser;
/**
 * Servlet implementation class BaseServlet
 */
public class BaseServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected DemiChatModule chatMod;   
	protected DemiUser demiUser;
	protected DemiBoard demiBoard;
	
    protected ServletContext sc;
    protected PrintWriter out;
    protected String reqFunc;
    protected HttpSession session;
    /**
     * @see HttpServlet#HttpServlet()
     */
    
    public BaseServlet() {
        super();
        chatMod=new DemiChatModule();
        demiUser=new DemiUser();
        demiBoard=new DemiBoard();
        // TODO Auto-generated constructor stub
        
    }

    protected void initServlet(HttpServletRequest request, HttpServletResponse response) throws IOException
    {
    	/*DB메니져 생성자를 실행함:)*/
    	DBManager.getDbm();
    	/*request와 reponse의 인코딩 설정*/
    	request.setCharacterEncoding("utf-8");
    	response.setContentType("text/plain;charset=UTF-8"); 
    	/*아웃 스트림을 받는다*/
    	out=response.getWriter();
    	/*세션 받기*/
    	session=request.getSession();
    	/*유저 클래스에 session을 넘김*/
    	demiUser.initDemiUser(session);
    	/*리퀘스트 목적*/
    	reqFunc=gFunction.getNotNull(request.getParameter("reqFunc"),"");
    	System.out.println(reqFunc);

    }
    protected void releaseServlet()
    {
    	out.close();
    }
    

    
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
